<template>
  <div>
    <h3>SubItem组件</h3>
    <p>已知库存数: {{ count }}</p>
    <button @click="subFn">库存-1</button>
    <button @click="asyncSubFn">库存-6</button>
  </div>
</template>

<script>
// 按需导入mapState,因为vuex对mapState是按需导出的
import { mapState, mapMutations, mapActions } from 'vuex'
export default {
  computed: {
    ...mapState(['count'])
  },
  methods: {
    ...mapMutations(['subCount']),
    ...mapActions(['asyncSubCount']),
    subFn() {
      this.subCount()
    },
    asyncSubFn() {
      this.asyncSubCount(6)
    }
  }
}
</script>

<style></style>
